<?php
/*
 * Created on 11 juin 2009
 * Created by Ludovic Reenaers
 * lreenaers@hotmail.com
 * 
 * 
 * $class = new ReflectionClass('TheClass');
if ($class->implementsInterface('IInterface'))
{
  print "Yep!\n";
}

 */
 class LoginFormGenerator extends Generator implements Wrapable{
	protected $children = array();
	
	public function setChildren($childArray){
		$bool = true;
		foreach ($childArray as $child){
			if (!is_a( $child, "Generator")){
				$bool = false;
			}
		}
		if($bool){
			$this->children = $childArray;
		}else{
			throw new Exception ("Array must only contains Generators.!");
		}
	}
 	public function getChildren(){
 		return $this->children;
 	}
 	public function addChild($Child){
 		if (is_a($Child, "Generator")){
 			array_push($this->children, $Child);
 		}else{
 			throw new Exception("you can only add Generators.");
 		}
 	} 	
 	function setUp(){
 		if ($_SESSION["USER_BEAN"]->getEmail()<>"admin@rpg.com"){
 			$mailvalue = $_SESSION["USER_BEAN"]->getEmail();
 		}else{
 			$mailvalue="";
 		}
		$labels = array('{url}','{maillabel}','{pwslabel}','{logbutton}','{register}','{forgot}','{mailinfo}','{pwsinfo}','{rememberme}','{encoding}','{mailvalue}','{ERROR-HERE}');
		$values = array($_SESSION['controler'],$this->translator->mail,$this->translator->pws,$this->translator->login,$this->translator->register,$this->translator->forgotpws,$this->translator->mailinfo,$this->translator->pwsinfo,$this->translator->rememberme,$_SESSION['encoding'],$mailvalue,$this->error);
 		$template = file_get_contents("../html/templates/showLogin");
 		$this->content .=str_replace($labels,$values,$template);
 	}
 	function dump(){
 		$this->setUp();
 		$wraped = "";
 		echo "ludo: in dump form";
 		foreach ($this->children as $child){
 			
 			$wraped.=$child->dump();
 		}
 		return str_replace("{WRAP-HERE}",$wraped,$this->content);
 	} 	
 }

?>
